package com.contractpage.ec;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.contractpage.common.persistence.Page;
import com.contractpage.ec.entity.Appoint;
import com.contractpage.ec.service.AppointService;
import com.contractpage.util.StringUtils;
import com.contractpage.util.UserUtils;

@Controller
@RequestMapping(value = "appoint")
public class AppointController extends BaseController{

	@Autowired
	private AppointService appointService;

	@RequestMapping(value = "findAllList")
	@ResponseBody
	public Object findAllList(Appoint entity, HttpServletRequest request, HttpServletResponse response, Model model){
		Page<Appoint> page = new Page<Appoint>(request,response);
		List<Appoint> list = appointService.findAllList(entity);
		page.setList(list);
		return page;
	}
	
	@RequestMapping(value = "findList")
	@ResponseBody
	public Object findList(Appoint entity, HttpServletRequest request, HttpServletResponse response, Model model){
		Page<Appoint> page = new Page<Appoint>(request,response);
		page = appointService.findList(page, entity);
		return page;
	}
	@RequestMapping(value = "save")
	@ResponseBody
	public Object save(Appoint entity, HttpServletRequest request, HttpServletResponse response, Model model){
		setUser(entity);
		return StringUtils.isEmpty(entity.getId())?appointService.update(entity):appointService.insert(entity);
	}
	@RequestMapping(value = "delete")
	@ResponseBody
	public Object delete(Appoint entity, HttpServletRequest request, HttpServletResponse response, Model model){
		return appointService.delete(entity);
	}
}